<?php
require_once "../config.php";
require_once "../smarty.php";
require_once "../autoload.php";

try {
    $oUser = new User();

    $oUrl = new Url($NomHost, $oUser, $_GET['route']);
    $VariablesGet = $oUrl->getVariables();
    print_r($VariablesGet);

    $smarty->assign("NomHost", $NomHost);
    $smarty->assign("TitleWeb", $NomWeb);

    $smarty->assign("isLogged", FALSE);
    if ($oUser->isLogged()) $smarty->assign("isLogged", TRUE);
    
    $smarty->assign("isAdmin", FALSE);
    if ($oUser->isAdmin()) $smarty->assign("isAdmin", TRUE);

    $modul = $VariablesGet["seccio"]["modul"];
    if (file_exists("../moduls/".$modul."/index.php")) {
        include '../moduls/'.$modul.'/index.php';
    }

    $smarty->assign("Content", $Content);
    $smarty->display('modules/load.html');
    $smarty->clear_compiled_tpl();
} catch (Exception $e) {
    print "Error inesperado:<br />";
    print_r($e);
}

?>
